/** 
 * 自己的对话框
 */
class MeTalk extends egret.Sprite {
    private txt: string = "自己的对话框";
    private face: string;
    constructor(txt, face?) {
        super();
        this.txt = txt;
        this.face = face;
        this.once(egret.Event.ADDED_TO_STAGE, this.init, this);
    }

    private init() {
        const header = Main.createBitmapByName(`header_0_png`);
        this.addChild(header);

        const bg = new egret.Bitmap();
        const talk = new eui.Label();
        const face = new egret.Bitmap();
        this.addChild(bg);
        this.addChild(talk);
        this.addChild(face);

        bg.texture = RES.getRes("meTalk_png");
        talk.text = this.txt;
        if (this.face) face.texture = RES.getRes(this.face);
        talk.textColor = 0;
        bg.width = talk.width + 40 + face.width + 20;
        bg.x = - bg.width - 10;
        talk.x = bg.x + 20;
        talk.y = 20;

        face.x = talk.x + talk.width + 10;
        face.y = talk.y - 3;


        this.x = this.stage.stageWidth - header.width - 20;
        this.y = Params.bufferTalk;
        Params.bufferTalk += this.height + 30;
    }
}